import request from '@/utils/request'

// 获取底图列表
export function padQuery(params) {
  return request({
    method: 'get',
    url: '/pad/base/map/manage/query',
    params
  })
}

/**
 * 底图排序
 * @param {*} params
 * @returns
 */
export function padBasemapUpdateSort(data) {
  return request({
    method: 'post',
    url: '/pad/base/map/updateSort',
    data
  })
}

// 新增底图
export function padInsert(data, str) {
  return request({
    method: 'post',
    url: `/pad/base/map/add?${str}`,
    data: data
  })
}

// 修改底图
export function padUpdate(data, str, pkid) {
  return request({
    method: 'put',
    url: `/pad/base/map/update/${pkid}?${str}`,
    data: data
  })
}

// 删除底图
export function padDelete(pkid) {
  return request({
    method: 'delete',
    url: `/pad/base/map/delete?pkid=${pkid}`
  })
}

//  上传缩略图
export function uploadImage(data) {
  return request({
    method: 'post',
    url: '/resource/mapBase/upload',
    data
  })
}

// 新增历史影像
export function padServiceAdd(data) {
  return request({
    method: 'post',
    url: '/resource/mapbase/service/add',
    data: data
  })
}

// 删除历史影像
export function padServiceDelete(pkid) {
  return request({
    method: 'delete',
    url: `/resource/mapbase/service/delete?pkid=${pkid}`
  })
}

// 修改历史影像
export function padServiceUpdate(data, pkid) {
  return request({
    method: 'put',
    url: `/resource/mapbase/service/update/${pkid}`,
    data: data
  })
}

// 查询底图
export function padServiceQuery(id) {
  return request({
    method: 'get',
    url: `/resource/mapbase/query/id?pkid=${id}`
  })
}

// 专题默认地图添加
export function padBaseSpecialAdd(data) {
  return request({
    method: 'post',
    url: '/resource/mapbase/special/add',
    data: data
  })
}

// 专题默认地图删除
export function padBaseSpecialDelete(pkid, specialType) {
  return request({
    method: 'delete',
    url: `/resource/mapbase/special/delete?mapBaseId=${pkid}&specialType=${specialType}`
  })
}

// 更新排序
export function catalogServiceUpdateSort(data) {
  return request({
    method: 'post',
    url: `/pad/catalog/service/updateSort`,
    data
  })
}

// 根据类型获取目录树 typeId
export function treeByTypeId(treeType) {
  return request({
    method: 'get',
    url: `/pad/catalog/query?type=${treeType}`
  })
}

// 目录树新增
export function treeAdd(data) {
  return request({
    method: 'post',
    url: '/pad/catalog/addOrUpdate',
    data
  })
}

// 目录树删除
export function treeDelete(pkid) {
  return request({
    method: 'delete',
    url: `/pad/catalog/delete?pkid=${pkid}`
  })
}

// 服务新增
export function serviceAdd(data) {
  return request({
    method: 'post',
    url: '/pad/catalog/service/addOrUpdate',
    data
  })
}

// 服务删除
export function serviceDelete(pkid) {
  return request({
    method: 'delete',
    url: `/pad/catalog/service/delete?pkid=${pkid}`
  })
}

// 查询apk列表
export function queryApkList() {
  return request({
    method: 'get',
    url: '/pad/version/query'
  })
}

// 新增/编辑apk文件
export function addOrUpdateApk(data) {
  return request({
    method: 'post',
    url: '/pad/version/addOrUpdate',
    data: data
  })
}

// 删除apk文件
export function deleteApk(sha1) {
  return request({
    method: 'delete',
    url: `/pad/version/delete?sha1=${sha1}`
  })
}

// 上传apk文件
export function uploadApkFile(formData) {
  return request({
    method: 'post',
    url: '/resource/file/upload/file?type=app',
    data: formData
  })
}
